#include <iostream>
#include <vector>
using namespace std;

vector<int> twoSum(vector<int> &price, int target)
{
    int left = 0;
    int right = price.size() - 1;
    while (left < right)
    {
        if (price[left] + price[right] > target)
        {
            right--;
        }
        else if (price[left] + price[right] < target)
        {
            left++;
        }
        else
        {
            return {price[left], price[right]};
        }
    }
    // 照顾编译器
    return {-1, -1};
}

int main()
{
    vector<int> v = {3, 9, 12, 15};
    int target = 18;
    cout << twoSum(v, target)[0] << " " << twoSum(v, target)[1] << endl;
    return 0;
}